package com.code.google.mdsc.gui.listener;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.JProgressBar;

import com.code.google.mdsc.io.log.SimpleLogger;
import com.code.google.mdsc.io.log.impl.SimpleLoggerImpl;

/**
 * 
 * 
 */
public class JProgressBarListener implements PropertyChangeListener {

	private final JProgressBar progressBar;

	private static SimpleLogger logger = SimpleLoggerImpl.getInstance();

	/**
	 * 
	 * @param progressBar
	 */
	public JProgressBarListener(JProgressBar progressBar) {
		this.progressBar = progressBar;
	}

	@Override
	public void propertyChange(PropertyChangeEvent evt) {

		logger.log(SimpleLogger.LogMode.DEBUG, evt.getPropertyName()
				+ " property was fired from: " + evt.getSource().toString());
		if ("progress".equals(evt.getPropertyName())) {
			int progress = (Integer) evt.getNewValue();
			progressBar.setValue(progress);
		}
	}

}
